﻿using UnityEngine;
using System.Collections;
using com.gzc.zgxq.game;

// 所谓接口就是 Can Do XXX，通常是一种行为。
public interface IPlayChess {
    int MovePiece (int mv, int pcCaptured);
    void UndoMovePiece (int mv, int pcCaptured);
}

/// <summary>
/// 棋手类
/// </summary>
public class ChessPlayerModel : IPlayChess {
    public RedBlackSide SidePlayer { get; private set; }    

    public ChessPlayerModel (RedBlackSide sidePlayer) {
        SidePlayer = sidePlayer;
    }

    public int MovePiece (int mv, int pcCaptured) {
        return 0;
    }
    public void UndoMovePiece (int mv, int pcCaptured) { }    
} 

public class ChessGameModel {

    public ChessBoardModel ChessBoardModel { get; private set; }
    ChessRuleModel chessRuleModel;

    public ChessPlayerModel RedPlayer { get; private set; }
    public ChessPlayerModel BlackPlayer { get; private set; }

    public ChessGameModel (RedBlackSide initSide) {
        Create( );
        InitSidePlayer(initSide);      
    }

    void Create ( ) {
        ChessBoardModel = new ChessBoardModel( );
        chessRuleModel = new ChessRuleModel( );

        RedPlayer = new ChessPlayerModel(RedBlackSide.RED);
        BlackPlayer = new ChessPlayerModel(RedBlackSide.BLACK);
    }

    void InitSidePlayer (RedBlackSide initSide) {
        SidePlayer = initSide;
    }

    /// <summary>
    /// 轮到谁走
    /// </summary>
    public RedBlackSide SidePlayer { get; private set; }

    /// <summary>
    /// 交换走子方
    /// </summary>
    public void ChangeSide ( ) {
        if (SidePlayer == RedBlackSide.RED) {
            SidePlayer = RedBlackSide.BLACK;
        } else {
            SidePlayer = RedBlackSide.RED;
        }        
    }

    /// <summary>
    /// 判断是否被将死
    /// </summary>   
    public bool IsMate ( ) {
        return false;
    }

}
